<template>
  <div>
    <el-row :gutter="10">
      <el-col :span="4">
        <div class="grid-content bg-purple-dark">
          <el-input v-model="search" circle placeholder="请输入用户姓名"></el-input>
        </div>
      </el-col>
      <el-col :span="4" :offset="1">
        <div class="grid-content bg-purple-dark">
          <el-date-picker
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            v-model="date"
            type="date"
            placeholder="选择出院时间"
          >
          </el-date-picker>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple-dark">
          <el-input
            v-model="phone"
            circle
            placeholder="请选择病床号"
          ></el-input>
        </div>
      </el-col>
      <el-col :span="2">
        <div class="grid-content bg-purple-dark">
          <el-button
            type="primary"
            @click="submit"
            icon="el-icon-search"
            circle
          ></el-button>
        </div>
      </el-col>
    </el-row>

    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection"> </el-table-column>
      <el-table-column label="住院号">
        <template slot-scope="scope">{{ scope.row.num }}</template>
      </el-table-column>
      <el-table-column label="姓名">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
      <el-table-column label="性别">
        <template slot-scope="scope">{{ scope.row.sex }}</template>
      </el-table-column>
      <el-table-column label="年龄">
        <template slot-scope="scope">{{ scope.row.age }}</template>
      </el-table-column>
      <el-table-column label="病床号">
        <template slot-scope="scope">{{ scope.row.chuanghao }}</template>
      </el-table-column>
      <el-table-column label="主治医生">
        <template slot-scope="scope">{{ scope.row.doctors }}</template>
      </el-table-column>
      <el-table-column label="护士">
        <template slot-scope="scope">{{ scope.row.nusers }}</template>
      </el-table-column>
      <el-table-column label="科室">
        <template slot-scope="scope">{{ scope.row.status }}</template>
      </el-table-column>
      <el-table-column label="入院时间">
        <template slot-scope="scope" v-if="scope.row.blo">
          {{ scope.row.date }}
        </template>
      </el-table-column>
      <el-table-column label="核准">
        <template slot-scope="scope">
          {{ scope.row.zdtype }}
        </template>
      </el-table-column>
      <el-table-column label="出院时间">
        <template slot-scope="scope" v-if="scope.row.blo">
          {{ scope.row.date }}
        </template>
      </el-table-column>
      <el-table-column label="操作" class="cellwidth">
        <template slot-scope="scope">
          <i class="el-icon-edit" @click="dit(scope.row)"></i>
          <i
            class="el-icon-circle-close"
            @click="dlele(scope.row.chuanghao)"
          ></i>
        </template>
      </el-table-column>
    </el-table>
  <el-row :gutter="10">
        <el-col :span="3"><el-button type="danger" @click="delmany">批量删除</el-button></el-col>
        <el-col :span="10"
          ><div class="block">
            <el-pagination
              @size-change="handleSizeChange"
              :current-page.sync="currentPage3"
              :page-size="100"
              layout="prev, pager, next, jumper"
              :total="1000"
            >
            </el-pagination></div
        ></el-col>
        
      </el-row>
  </div>
</template>

<script>
export default {
  name: "outlist",
  data() {
    return {
          phone:"",
      zhuyuanhao:"",
      bingchuanghao:"",
        currentPage3:5,
      search: "",
      date: "",
      tableData: [
        // {
        //   date: "2016-05-03",
        //   name: "王小虎1",
        //   address: "上海市普陀区金沙江路 1518 弄",
        // }
        {
          num: "01",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3028,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "外科",
          blo: false,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
        {
          num: "02",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3029,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "内科",
          blo: true,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
        {
          num: "03",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3030,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "妇科",
          blo: false,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
        {
          num: "04",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3031,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "精神科",
          blo: false,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
        {
          num: "05",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3032,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "核准",
          blo: true,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
        {
          num: "06",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3033,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "牙科",
          blo: true,
          city: "郑州",
          zdtype: "核准",
          bingli:"神经错乱",
          date: "2020-12-8",
        },
      ],
      multipleSelection: [], //我把选中的每一个放入这个数组里面
    };
  },
  methods: {
    dit(rows) {
      //编辑
      // console.log(i);
     sessionStorage.setItem('row',JSON.stringify(rows))

      this.$router.push({path:'/index/outindex/outdayin',query:{row:rows}})
    },
    dlele(num) {
      // var newarr=""
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].chuanghao == num) {
          this.tableData.splice(i,1)
          return
        }
      }
    },
    submit() {
      console.log(this.search, this.date);
    },
  handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
    delmany() {
      console.log(this.multipleSelection);
      for (let i = 0; i < this.tableData.length; i++) {
        for (let j = 0; j < this.multipleSelection.length; j++) {
          if (this.tableData[i] == this.multipleSelection[j]) {
            this.tableData.splice(i, 1);
          }
        }
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
  },
};
</script>

<style lang="scss"  scoped>
// .cellwidth{
//     // text-align: center !important;
//     // padding: 0 !important;
//     background: black;
// }
.el-icon-edit {
  padding-right: 20px;
  font-size: 18px;
  color: #16dcb8;
  cursor: pointer;
}
.el-icon-circle-close {
  font-size: 18px;
  color: #16dcb8;
  cursor: pointer;
}
</style>